<div id="main-content">
  <div class="container-fluid">
    <div class="row-fluid">
      <div class="span12">
        <div class="widget-block">
          
          <div class="widget-head">
            <h5><?=$title_table?></h5>
            <div class="widget-control pull-right">
              <a href="#" data-toggle="dropdown" class="btn dropdown-toggle"><i class="icon-cog"></i><b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="<?=  site_url("customer-service/add-kategori-pica") ?>"><i class="icon-plus"></i> Add New</a></li>
              </ul>
            </div>
          </div>
          <div class="widget-content">
            <div class="widget-box">
              <table class="<?php print $boxy?> table">
                <thead>
                  <tr>
                    <th><?php print $berdasarkan?></th>
                    <th>Outlet</th>
                    <th>Information</th>
                    <th>Problem Identifikasi</th>
                    <th>Corrective Action</th>
                    <th>Date</th>
                  </tr>
                </thead>
                <tbody>
                  <?php
                  $topik = array(
                      1 => "SDM",
                      2 => "Service",
                      3 => "Administrasi",
                      4 => "Promo",
                      5 => "Tools",
                      6 => "IT - Software & Hardware",
                      7 => "Parts",
                      9 => "Lainnya"
                  );
                  $sumber = array(
                      1 => "Email",
                      2 => "Telphone",
                      3 => "Pesan Singkat",
                  );
                  $status = array(
                      0 => "<span class='label'>Draft</span>",
                      1 => "<span class='label label-info'>Progress</span>",
                      2 => "<span class='label label-success'>Finish</span>",
                  );
                  $panggilan = array(
                      1 => "Bapak",
                      2 => "Ibu",
                  );
                  if(is_array($data)){
                    foreach ($data as $key => $value) {
                      $informasi = "
                        Topik : {$topik[$value->kategori]} <br />
                        Kategori : {$value->kategori_pica} <br />
                        Sumber : {$sumber[$value->sumber_info_view]} <br />
                        Status : {$status[$value->fix]} <br />
                        Pelapor : {$panggilan[$value->panggilan]} {$value->nama_pelapor} <br />
                        Email : {$value->email_pelapor} <br />
                        Telphone : {$value->telp_pelapor}
                        ";
                        
                      $awal_time = strtotime($value->tanggal_buat);
                      $selesai_time = strtotime($value->tanggal_selesai);
                      $over_time = strtotime($value->due_date);
                      if($value->tanggal_selesai)
                        $sekarang = gregoriantojd(date("m", $selesai_time), date("d", $selesai_time), date("Y", $selesai_time));
                      else
                        $sekarang = gregoriantojd(date("m"), date("d"), date("Y"));

                      $awal_laporan = gregoriantojd(date("m", $awal_time), date("d", $awal_time), date("Y", $awal_time));
                      $lama_laporan = $sekarang - $awal_laporan;

                      if($value->tanggal_selesai){
                        $selesai_laporan = gregoriantojd(date("m", $selesai_time), date("d", $selesai_time), date("Y", $selesai_time));
                        $lama_pengerjaan = $selesai_laporan - $awal_laporan;
                        $sekarang_over = $selesai_laporan;
                      }
                      else{
                        $lama_pengerjaan = "-";
                        $sekarang_over = $sekarang;
                      }

                      $over_laporan = gregoriantojd(date("m", $over_time), date("d", $over_time), date("Y", $over_time));
                      $lama_kelewatan =  $sekarang_over - $over_laporan;
                        
                      $tanggalan = "
                        Report Date : {$value->tanggal_buat} <br />
                        Due Date : {$value->due_date} <br />
                        Finish Date : {$value->tanggal_selesai} <br />
                        Lama Laporan : {$lama_laporan} <br />
                        Over Due : {$lama_kelewatan} <br />
                        PIC : {$value->pic} <br />
                        ";
                        
                      print "
                  <tr>
                    <td style='width: 80px'>{$value->$tanggal_inisialisasi}</td>
                    <td style='width: 150px'>{$value->outlet}</td>
                    <td style='width: 200px'>{$informasi}</td>
                    <td style='width: 200px'>".nl2br($value->problem)."</td>
                    <td style='width: 200px'>".nl2br($value->corrective)."</td>
                    <td>{$tanggalan}</td>
                  </tr>";
                    }
                  }
                  ?>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
    
  </div>
</div>